/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * This file is part of retabel.
 *
 * Copyright (c) 2011 by individual contributors as indicated by the
 * @author tags. See the copyright.txt file in the distribution
 * for a full listing of individual contributors.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */

package org.retabel.persistence.entity.report;

import javax.persistence.*;

/**
 * Entity class for report designs.
 * <p/>
 * <h3>Extra-Info</h3>
 * Created: 23:11 21.06.11
 *
 * @author Burt Parkers
 * @version 1.0
 */
@Entity
@Table(uniqueConstraints = @UniqueConstraint(columnNames = {"reportDesignPackage", "name"}))
public class ReportDesign {

    /** The id field. */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int id;

    /** Name of the design */
    @Column(nullable = false, length = 50)
    private String name;

    /** Content of the design. */
    @Lob
    @Basic(fetch = FetchType.LAZY)
    @Column(nullable = false)
    private byte[] content;

    /** The report design package the report designs belong to */
    @ManyToOne(optional = false)
    @JoinColumn(name = "reportDesignPackage")
    private ReportDesignPackage reportDesignPackage;

    /**
     * Returns the id.
     *
     * @return the id.
     */
    public int getId() {
        return id;
    }

    /**
     * Sets the id.
     *
     * @param id the id.
     */
    public void setId(int id) {
        this.id = id;
    }

    /**
     * Gets the content.
     *
     * @return The content value.
     */
    public byte[] getContent() {
        return content;
    }

    /**
     * Sets the content.
     *
     * @param content The content value to set.
     */
    public void setContent(byte[] content) {
        this.content = content;
    }

    /**
     * Gets the reportDesignPackage.
     *
     * @return The reportDesignPackage value.
     */
    public ReportDesignPackage getReportDesignPackage() {
        return reportDesignPackage;
    }

    /**
     * Sets the reportDesignPackage.
     *
     * @param reportDesignPackage The reportDesignPackage value to set.
     */
    public void setReportDesignPackage(ReportDesignPackage reportDesignPackage) {
        this.reportDesignPackage = reportDesignPackage;
    }

    /**
     * Gets the name.
     *
     * @return The name value.
     */
    public String getName() {
        return name;
    }

    /**
     * Sets the name.
     *
     * @param name The name value to set.
     */
    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "ReportDesign{" + "content=" + content + ", id=" + id + ", name='" + name + '}';
    }
}
